<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl() ?>/public/css/input.css"/>
<form id="input2" method="POST" enctype="multipart/form-data" autocomplete="off">
    <input type="hidden" name="dunnage_id" value="<?php echo $this->id ?>"/>
    <div id="input-content">
        <div class="input-step">
            <table class="timeline" width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <th scope="col">General infomation</th>
                    <th class="current" scope="col">Dunnage</th>
                    <th scope="col">Tally</th>
                    <th scope="col">Cargo supervision</th>
                </tr>
            </table>
            <div class="step-content">
                <h1 class="first"> DUNNAGE MATERIAL</h1>
                <table id="input2" width="100%" border="0" cellpadding="0" cellspacing="0" class="row">
                    <tr>
                        <th scope="col" class="number" width="3%">Number</th>
                        <th scope="col" class="type" width="15%">Type</th>
                        <th scope="col" class="unit">Unit</th>
                        <th scope="col" class="price">Price per unit</th>
                        <th scope="col" class="EDU">Estimated dunnage<br>usage</th>
                        <th scope="col" class="FDU">Final dunnage<br>usage</th>
                        <th scope="col" class="EDC">Estimated dunnage <br>cost (USD)</th>
                        <th scope="col" class="FDC">Final dunnage <br>cost (USD)</th>
                    </tr>
                    <?php $index = 0; ?>
                    <?php foreach ($this->dunnage_services as $dunnage_service): ?>
                        <tr>
                        <input type="hidden" name="dunnage_material_id[]" value='<?php echo $dunnage_service->id ?>'/>
                        <td class="number">
                            <?php echo++$index ?>
                        </td>
                        <td class="type"><?php echo $dunnage_service->type ?></td>
                        <td class="unit"><?php echo $dunnage_service->unit ?></td>
                        <td class="price">
                            <?php echo $dunnage_service->price_per_unit ?>
                        </td>
                        <td class="EDU">
                            <input <?php echo ($this->dunnage_material && isset($this->dunnage_material[$dunnage_service->id])) ? "value='" . $this->dunnage_material[$dunnage_service->id]["estimated_dunnage_usage"] . "'" : "" ?> type="text" class="estimated_dunnage_usage entertext" placeholder="Enter text" name="estimated_dunnage_usage[]"/>
                        </td>
                        <td class="FDU">
                            <input <?php echo ($this->dunnage_material && isset($this->dunnage_material[$dunnage_service->id])) ? "value='" . $this->dunnage_material[$dunnage_service->id]["final_dunnage_usage"] . "'" : "" ?> type="text" class="final_dunnage_usage entertext" placeholder="Enter text" name="final_dunnage_usage[]"/>
                        </td>
                        <td class="EDC">
                            <input <?php echo ($this->dunnage_material && isset($this->dunnage_material[$dunnage_service->id])) ? "value='" . $this->dunnage_material[$dunnage_service->id]["estimated_dunnage_cost"] . "'" : "" ?> type="text" class="estimated_dunnage_cost entertext" name="estimated_dunnage_cost[]" readonly="true"/>
                        </td>
                        <td class="FDC">
                            <input <?php echo ($this->dunnage_material && isset($this->dunnage_material[$dunnage_service->id])) ? "value='" . $this->dunnage_material[$dunnage_service->id]["final_dunnage_cost"] . "'" : "" ?> type="text" class="final_dunnage_cost entertext" name="final_dunnage_cost[]" readonly="true"/>
                        </td>
                        </tr>
                    <?php endforeach; ?>
                    <tr>
                        <td align="center" class="total" colspan="3">Total</td>
                        <td class="totalval">
                            <input type="text" class="entertext" id="totalval" disabled="true"/>
                        </td>
                    </tr>
                </table>
                <h1> DUNNAGE OPERATIONS</h1>
                <div class="cleft">
                    <div class="item">
                        <label for="VAaps">Vessel arrived at p/s</label>
                        <div class="reselect">
                            <input <?php if ($this->dunnage_operation): ?>value="<?php echo date(DATE_FORMAT, $this->dunnage_operation->vessel_arrived_at_ps); ?>"<?php endif; ?> type="text" name="vessel_arrived_at_ps" class="datetime" placeholder="Datetime"/>
                        </div>
                    </div>
                    <div class="item">
                        <label for="VAab">Vessel arrived at buoy.</label>
                        <div class="reselect">
                            <input <?php if ($this->dunnage_operation): ?>value="<?php echo date(DATE_FORMAT, $this->dunnage_operation->vessel_arrived_at_buoy); ?>" <?php endif; ?> type="text" name="vessel_arrived_at_buoy" class="datetime" placeholder="Datetime"/>
                        </div>
                    </div>
                </div>
                <div class="cright">
                    <div class="item">
                        <label for="ClD">Commenced dunnaging</label>
                        <div class="reselect">
                            <input <?php if ($this->dunnage_operation): ?>value="<?php echo date(DATE_FORMAT, $this->dunnage_operation->commenced_dunnaging); ?>" <?php endif; ?> type="text" name="commenced_dunnaging" class="datetime" placeholder="Datetime"/>
                        </div>
                    </div>
                    <div class="item">
                        <label for="CmD">Completed dunnaging</label>
                        <div class="reselect">
                            <input <?php if ($this->dunnage_operation): ?>value="<?php echo date(DATE_FORMAT, $this->dunnage_operation->completed_dunnaging); ?>" <?php endif; ?> type="text" name="completed_dunnaging" class="datetime" placeholder="Datetime"/>
                        </div>
                    </div>
                </div>
                <div style="clear: both;">&nbsp;</div>
                <h1 class="table">UPDATE DUNNAGE OPERATIONS</h1>  
                <?php if ($this->dunnage_operation): ?>
                    <table id="input2" width="100%" border="0" cellpadding="0" cellspacing="0" class="row">
                        <tr>
                            <th scope="col" class="date">Date</th>
                            <?php foreach ($this->update_dunnage_operation_cols as $update_dunnage_operation_col => $name): ?>
                                <th scope="col" class="item-label">
                                    <?php echo $name ?>
                                </th>
                            <?php endforeach; ?>
                            <th scope="col"></th>
                        </tr>
                        <?php foreach ($this->update_dunnage_operations as $update_dunnage_operation): ?>
                            <tr id='tr_<?php echo $update_dunnage_operation->id ?>'>
                                <td scope="col" class="date">
                                    <?php echo date(DATE_FORMAT, $update_dunnage_operation->date) ?>
                                </td>
                                <?php foreach ($this->update_dunnage_operation_cols as $update_dunnage_operation_col => $name): ?>
                                    <td scope="col">
                                        <div class="file-wrapper">
                                            <img src='<?php echo UPLOAD_URL . $update_dunnage_operation->$update_dunnage_operation_col ?>' width='80%' height='90%'/>
                                        </div>
                                    </td>
                                <?php endforeach; ?>
                                <td width='4%'>
                                    <a href='javascript:void(0' onclick='deleteUpdateDunnageOperation("<?php echo $update_dunnage_operation->id ?>")'>
                                        <img src='<?php echo $this->baseUrl() ?>/public/images/delete.gif'/>
                                    </a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </table>
                <?php endif; ?>
                <div style='width:40%;margin-top: 3%'>
                    <label style='float:none;margin-right: 5%'>Date</label>
                    <div style="display:inline-block;width:60%">
                        <input type='text' name='update_dunnage_date' class='datetime' style='float:none' placeholder='Enter update time'/>
                    </div>
                </div>
                <div class="cleft">
                    <div class='item'>
                        <label>Laying draft paper</label>
                        <div class="reselect">
                            <input type='file' name='laying_draft_paper' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['laying_draft_paper']) ? "" : "disabled" ?>/>
                        </div>
                    </div>
                    <div class='item'>
                        <label>Laying plastic sheets</label>
                        <div class="reselect">
                            <input type='file' name='laying_plastic_sheets' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['laying_plastic_sheets']) ? "" : "disabled" ?>/>
                        </div>
                    </div>    
                    <div class='item'>
                        <label>Sawdust in frame</label>
                        <div class="reselect">
                            <input type='file' name='sawdust_in_frame' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['sawdust_in_frame']) ? "" : "disabled" ?>/>
                        </div>
                    </div>                      
                    <div class='item'>
                        <label>Styrofoam in frame</label>
                        <div class="reselect">
                            <input type='file' name='styrofoam_in_frame' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['styrofoam_in_frame']) ? "" : "disabled" ?>/>
                        </div>
                    </div>  
                </div>
                <div class='cright'>
                    <div class='item'>
                        <label>Kraft paper on top</label>
                        <div class="reselect">
                            <input type='file' name='kraft_paper_on_top' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['kraft_paper_on_top']) ? "" : "disabled" ?>/>
                        </div>
                    </div>
                    <div class='item'>
                        <label>Laying bamboo mats</label>
                        <div class="reselect">
                            <input type='file' name='laying_bamboo_mats' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['laying_bamboo_mats']) ? "" : "disabled" ?>/>
                        </div>
                    </div>      
                    <div class='item'>
                        <label>Laying bamboo sticks</label>
                        <div class="reselect">
                            <input type='file' name='laying_bamboo_sticks' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['laying_bamboo_sticks']) ? "" : "disabled" ?>/>
                        </div>
                    </div>     
                    <div class='item'>
                        <label>Laying ballets</label>
                        <div class="reselect">
                            <input type='file' name='laying_ballets' <?php echo!$this->update_dunnage_operation_cols || isset($this->update_dunnage_operation_cols['laying_ballets']) ? "" : "disabled" ?>/>
                        </div>
                    </div>    
                </div>        
                <div style="clear: both;">&nbsp;</div>
                <h1 class="table">DOCUMENTS</h1>
                <div id="new-document">
                    <span id="mask-new-file"></span>
                    <div id="upload-progress" style="display:none"></div>
                </div>
                <?php if ($this->dunnage_document): ?>
                    <?php foreach ($this->dunnage_document as $doc): ?>
                        <div class="<?php echo $doc['file_type'] ?> file-new">
                            <span>
                                <?php echo $doc['file_name'] ?>
                            </span>
                            <a href='javascript:void(0)' class='delete-file' onclick='deleteUploadFile(event, "<?php echo $doc['file'] ?>", <?php echo $doc['id'] ?>, "Dunnage")'>
                                <img src='<?php echo $this->baseUrl() ?>/public/images/delete.gif'>
                            </a>
                        </div>
                    <?php endforeach; ?>
                <?php endif; ?>
                <div class="file-wrapper" style="padding-top:10px" id="wrap_upload_buttons">
                    <span class="button" id="add_file">Add Files</span>          
                </div>
                <div style="clear: both;">&nbsp;</div>
            </div>
            <div class="next"><input type="submit" class="next" value="<?php if ($this->id): ?>Update <?php else: ?> SAVE &amp; CONTINUE <?php endif; ?>" /></div>
        </div>
        <div style="clear: both;">&nbsp;</div>
    </div>
</form>
<div id='confirm_dialog'>
    Are you really sure you want to delete this?
</div>
<script>
                                        var ref_no = '<?php echo $this->ref_no ?>';
</script>

<link rel='stylesheet' type='text/css' href='<?php echo $this->baseUrl() ?>/public/css/jquery-ui/jquery-ui-1.10.3.css'/>
<script src='<?php echo $this->baseUrl() ?>/public/js/jquery-ui-1.10.3.js'></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/plupload/plupload.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/plupload/plupload.gears.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/plupload/plupload.silverlight.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/plupload/plupload.flash.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/plupload/plupload.browserplus.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/plupload/plupload.html4.js"></script>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/plupload/plupload.html5.js"></script>
<script src='<?php echo $this->baseUrl() ?>/public/js/newservice.js'></script>
<script src="<?php echo $this->baseUrl() ?>/public/js/newdunnage.js"></script>

<style>
    .ui-progressbar {
        width: 200px;
        height: 10px;
    }
</style>